<script lang="ts" setup>
import { useTheme } from "@/hooks/useTheme"
import { onMounted } from "vue"
// 将 Element Plus 的语言设置为中文
import zhCn from "element-plus/es/locale/lang/zh-cn"
import { useUserStore } from "./store/modules/user"
import { getToken } from "./utils/cache/cookies"
import Speech from "./utils/speech"
const token = getToken()
const { initTheme } = useTheme()
const { user, getInfo } = useUserStore()

/** 初始化主题 */
initTheme()

onMounted(() => {
  Speech.instance.init()

  //如果token user消息不存在即拉取
  if (!!token && !user) {
    getInfo()
  }
})
</script>

<template>
  <el-config-provider :locale="zhCn">
    <router-view />
  </el-config-provider>
</template>
